<?php
/**
 * 专营店反馈项目信息表
 * @author qianxun
 *
 */
class storeProModel extends MY_Model{
    function storeProModel(){
        parent::MY_Model();
        $this->table = 'StorePro';
    }
    /**
     * 获取标准动作完成率
     * @param number $storeId
     * @param number $timeUnit
     * @param number $year
     */
    function getStandardRate($storeId,$timeUnit,$year){
        //更改数据库链接配置
        $this->db = $this->load->database('implement', true);
        $findList = $this->getList(array('storeId'=>$storeId,'timeUnit'=>$timeUnit,'year'=>$year));
        $totalCount = 0;
        $passCount = 0;
        foreach ($findList as $v){
            $totalCount ++;
            if ($v['auditRs'] == 1){
                $passCount++;
            }
        }
        //查完之后将数据库链接设置回默认设置
        $this->db = $this->load->database('', true);
        return $totalCount ? ($passCount/$totalCount) * 100 : 0;
    }
}